from itsdangerous import TimedJSONWebSignatureSerializer
class Serretoauth(object):
    def Secret(self,openid):
        # 1.实例化对象
        TJSOB = TimedJSONWebSignatureSerializer(secret_key='saber',expires_in=3600*24*60)
        # 2.加密
        secret=TJSOB.dumps(openid)
        # secret是一个bytes类型，把它解码成字符串格式
        return secret.decode()

    def Unsecret(self,openid):
        TJSOB = TimedJSONWebSignatureSerializer(secret_key='saber', expires_in=3600*24*60)
        unsecret = TJSOB.loads(openid)
        return unsecret

if __name__ == '__main__':
    secretob = Serretoauth()
    secretob.Secret("openid")
    secretob.Unsecret(secretob.Secret("openid"))

